package helpers;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class DateHelper {
	public static List<Long> calDistanceTimeToNow(Date date) {
		List<Long> arr = new ArrayList<Long>();
		Date now = new Date();
		long seconds = (now.getTime() - date.getTime())/1000;
		long day = (int) (seconds / 86400);
		long hour = (int) ((seconds - day*86400) / 3600);
		long minute = (int) ((seconds - day*86400 - hour*3600) / 60);
		arr.add(day);
		arr.add(hour);
		arr.add(minute);
		arr.add(seconds);
		return arr;
	}
	
	public static List<Long> coundownFromNow(Date date) {
		List<Long> arr = new ArrayList<Long>();
		Calendar cal=Calendar.getInstance();
		Date now = new Date();
		cal.setTime(date);
		cal.add(Calendar.DATE, +3);
		
		long seconds = (cal.getTime().getTime() - now.getTime())/1000;
		long day = (int) (seconds / 86400);
		long hour = (int) ((seconds - day*86400) / 3600);
		long minute = (int) ((seconds - day*86400 - hour*3600) / 60);
		
		arr.add(day);
		arr.add(hour);
		arr.add(minute);
		arr.add(seconds);
		return arr;
	}
}
